public class Student implements  Cloneable{
    public int num;
    public String name;

    public static void main(String[] args) {
        //深拷贝
        Student s1 = new Student();
        s1.num = 10;
        s1.name="zhaoliu";
        System.out.println("s1的姓名和学号为"+s1.name+" "+s1.num);
        try {
            Student s2  = (Student)s1.clone();
            s2.name="zhangsan";
            s2.num = 1;
            System.out.println("s2的姓名和学号为："+s2.name+" "+s2.num);
            System.out.println("1111111111");
            System.out.println("s1的姓名和学号为"+s1.name+" "+s1.num);
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }


    }

    public static void main1(String[] args) {
        //浅拷贝
        Student s1 = new Student();
        s1.num=10;
        s1.name="zhangsan";
        Student s2 = s1;
        s2.num=8;
        s2.name="wangwu";
        System.out.println(s1.num+" "+s1.name);
        if(s1==s2){
            System.out.println("111");
        }
    }
}
